#include <bits/stdc++.h>

#define N 2000

using namespace std;

/*struct edge{
    int to;
    int dis;
};*/

struct node{
    int id;
    int dis;
    bool operator<(const node& other)const{
        return dis < other.dis;
    }
};

vector<int> G[N];
int dis[N];

void dijkstra(int scr){
    priority_queue<node> pq;
    dis[scr] = 0;
    pq.push((node){scr, 0});

    while(!pq.empty()){
        node u = pq.top(); pq.pop();
        if(u.dis > dis[u.id])   continue;
        for(int& e : G[u.id]){
            if(dis[e] > dis[u.id] + 1){
                dis[e] = dis[u.id] + 1;
                pq.push((node){e, dis[e]});
            }
        }
    }
}

int main(){
    fill(dis, dis + N, 0x7fffffff);
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        int tmp;
        scanf("%d", &tmp);
        if(i + tmp <= n){
            G[i].push_back(i + tmp);
        }
        if(i - tmp >= 0){
            G[i].push_back(i - tmp);
        }
    }
    dijkstra(a);
    if(dis[b] != 0x7fffffff) cout << dis[b];
    else cout << -1;
    return 0;
}